/*  
 *  Copyright 2006 Paul Jack.
 *
 *  This file is part of the Dex compiler suite. 
 *  
 *  Dex is free software; you can redistribute it and/or modify it
 *  under the terms of the GNU General Public License as published by the
 *  Free Software Foundation; either version 2 of the License, or (at your
 *  option) any later version.
 *  
 *  Dex is distributed in the hope that it will be useful, but
 *  WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 *  Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 */
package dex.compiler.problem;


import java.util.List;
import dex.compiler.model.base.Place;
import dex.compiler.model.program.Path;


/**
 * Thrown by AbortReporter when an ambiguity is reported.
 */
public class AmbiguityException extends ProblemException {

	
	/**
	 * Mandatory for exceptions.
	 */
	private static final long serialVersionUID = 6571840371677044055L;


	/**
	 * The name of the construct that was defined more than once.
	 */
	final private String name;
	
	
	/**
	 * The list of places where that construct was defined.
	 */
	final private List<Path> found;

	
	/**
	 * Constructs a new <code>AmbiguityException</code>.
	 * 
	 * @param ambiguity  the ambiguity that was reported
	 * @param place      the place where the ambiguity occurred
	 * @param name       the name of the construct that was defined more than once
	 * @param places     the places where that construct was defined
	 */
	public AmbiguityException(Ambiguity ambiguity, Place place, String name, List<Path> found) {
		super(ambiguity, place, ambiguity.toMessage(place, name, found));
		this.name = name;
		this.found = found;
	}


	/**
	 * Returns the ambiguity that was reported.
	 * 
	 * @return  the ambiguity that was reported.
	 */
	public Ambiguity getAmbiguity() {
		return (Ambiguity)getProblem();
	}


	/**
	 * Returns the name of the construct that was defined more than once.
	 * 
	 * @return  the name of the construct that was defined more than once.
	 */
	public String getName() {
		return name;
	}


	/**
	 * Returns the list of paths where the construct is defined.
	 * 
	 * @return  the list of paths where the construct is defined.
	 */
	public List<Path> getPaths() {
		return found;
	}


}
